package initialize

import (
	"go.uber.org/zap"
	"inventory_srv/global"
)

func NewLogger() (*zap.Logger, error) {
	flag := GetSystemConfig()
	if flag {
		config := zap.NewProductionConfig()
		config.OutputPaths = []string{
			global.ServerConfig.LogConfig.Path,
		}
		return config.Build()
	} else {
		development, err := zap.NewDevelopment()
		return development, err
	}
}

// 配置日志
func InitLogger() {
	logger, err := NewLogger()
	if err != nil {
		panic(err)
	}
	zap.ReplaceGlobals(logger)
}
